package ru.usu.gv.gui;

import ru.usu.gv.core.GraphCanvas;
import ru.usu.gv.gui.analysis.AnalysisPanel;
import ru.usu.gv.gui.dynamic.DynamicVisPanel;

import javax.swing.JFrame;
import javax.swing.JPanel;

import java.awt.BorderLayout;

/**
 @author: Sergey Pupyrev 
 Apr 2, 2006
 */

public class GUIEngine
{
	private static GUIEngine INSTANCE = new GUIEngine();

	private JFrame _mainFrame;

	public static GUIEngine getInstance()
	{
		return INSTANCE;
	}

	private GUIEngine()
	{
	}

	public void init(JFrame mainFrame)
	{
		_mainFrame = mainFrame;
		_mainFrame.getContentPane().setLayout(new BorderLayout());

		_mainFrame.getContentPane().add(BorderLayout.CENTER, new GraphCanvas());

		JPanel panels = new JPanel(new BorderLayout());
		panels.add(BorderLayout.WEST, AnalysisPanel.getInstance());
		panels.add(BorderLayout.EAST, DynamicVisPanel.getInstance());
		_mainFrame.getContentPane().add(BorderLayout.EAST, panels);
		
		_mainFrame.setJMenuBar(new GVMenuBar(GVActions.getInstance()));

	}

	public JFrame getMainFrame()
	{
		return _mainFrame;
	}

	public void setTitle(String title)
	{
		_mainFrame.setTitle("GraphVis: " + title);
	}
}
